cmake_minimum_required(VERSION 3.1)
# set(VCPKG_ROOT "c:/src/vcpkg/scripts/buildsystems/vcpkg.cmake")
# set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT})

project(
  sdk
  VERSION 0.0.1
  LANGUAGES CXX)

# find_package(unofficial-libuv CONFIG REQUIRED)
set(S 0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

set(root ${CMAKE_CURRENT_SOURCE_DIR})
# 设置目标Debug版本生成到指定路劲，便于调试运行。
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/out)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/out)
file(GLOB dlls "${root}/3rd/*.dll")
file(COPY ${dlls} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG})

# 设置目标release版本生成到指定路劲 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE
# ${PROJECT_SOURCE_DIR}/build/out) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE
# ${PROJECT_SOURCE_DIR}/build/out) 也可以同时设置debug和release版本的输出路径
# SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/out)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/out)
include_directories("include")
include_directories("include/imgui")
include_directories("ireader/include")
# include_directories("common" "network")

link_directories(${root}/3rd)
link_directories(${root}/3rd/ireader/lib)
link_directories(${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG})
link_directories(${root}/3rd/ireader/lib)

file(GLOB_RECURSE net "src/common/*.cpp" "src/network/*.cpp")
file(GLOB_RECURSE imgui "src/imgui-sdl2/*.cpp")
add_library(imgui ${imgui})
target_link_libraries(imgui SDL2 SDL2-2.0)

if(S)
  message("build shared netwrok")
  add_library(network SHARED ${net})
  target_link_libraries(network uv)
else()
  message("build static network")
  add_library(network ${net})
  # set_target_properties(network-shared PROPERTIES OUTPUT_NAME network
  # CLEAN_DIRECT_OUTPUT 1)
  target_link_libraries(network uv)
endif(S)

add_subdirectory(c-s)
add_subdirectory(test)
